package com.itangcent.idea.plugin.api.export.yapi

import com.google.inject.Inject
import com.itangcent.common.kit.toJson
import com.itangcent.common.model.Request
import com.itangcent.idea.plugin.api.export.core.requestOnly
import com.itangcent.idea.plugin.settings.SettingBinder
import com.itangcent.idea.plugin.settings.Settings
import com.itangcent.idea.utils.SystemProvider
import com.itangcent.intellij.context.ActionContext
import com.itangcent.mock.ImmutableSystemProvider
import com.itangcent.mock.SettingBinderAdaptor
import com.itangcent.mock.toUnixString
import com.itangcent.test.TimeZoneKit.STANDARD_TIME
import org.junit.jupiter.api.condition.OS

/**
 * Test case of [YapiFormatter]
 */
internal abstract class YapiFormatterTest : YapiSpringClassExporterBaseTest() {

    @Inject
    protected lateinit var yapiFormatter: YapiFormatter

    protected val settings = Settings()

    override fun beforeBind() {
        super.beforeBind()
        settings.inferEnable = true
    }

    override fun bind(builder: ActionContext.ActionContextBuilder) {
        super.bind(builder)
        builder.bind(SystemProvider::class) {
            it.toInstance(ImmutableSystemProvider(STANDARD_TIME))
        }
        builder.bind(SettingBinder::class) {
            it.toInstance(SettingBinderAdaptor(settings))
        }
    }

    override fun shouldRunTest(): Boolean {
        return !OS.WINDOWS.isCurrentOs
    }

    class YapiFormatterWithDefaultTest : YapiFormatterTest() {

        /**
         * use json-schema by default
         */
        fun testDoc2Items() {
            val requests = ArrayList<Request>()
            val boundary = actionContext.createBoundary()
            classExporter.export(userCtrlPsiClass, requestOnly {
                requests.add(it)
            })
            boundary.waitComplete(false)
            classExporter.export(defaultCtrlPsiClass, requestOnly {
                requests.add(it)
            })
            boundary.waitComplete()
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"string\\\",\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/greeting\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"say hello\",\"path\":\"/user/greeting\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"not update anything\",\"req_headers\":[],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":true,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003enot update anything\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[0]).toJson()
            )
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"}},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"user regtime\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/get/{id}\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"get user info\",\"path\":\"/user/get/{id}\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[\"deprecated\"],\"req_query\":[{\"name\":\"id\",\"value\":0,\"desc\":\"user id\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"undone\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[1]).toJson()
            )
            val apiCntInUserCtrl = userCtrlPsiClass.methods.size
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"string\\\",\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/ctrl/name\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"current ctrl name\",\"path\":\"/user/ctrl/name\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 0]).toJson()
            )
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"default\\\":\\\"[123, 456]\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"abc\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"123\\\"},\\\"def\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"abc\\\\\\\":\\\\\\\"123\\\\\\\",\\\\\\\"def\\\\\\\":\\\\\\\"456\\\\\\\"}\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"]\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"}\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"aaa\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"default\\\":\\\"[{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}}\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/body\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with query\",\"path\":\"/default/body\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[{\"name\":\"intArr[0]\",\"value\":123,\"example\":\"123\",\"desc\":\"\",\"required\":0},{\"name\":\"intArr[1]\",\"value\":456,\"example\":\"456\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.abc\",\"value\":\"123\",\"example\":\"123\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.def\",\"value\":\"456\",\"example\":\"456\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[0]\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[1]\",\"value\":\"123\",\"example\":\"123\",\"desc\":\"\",\"required\":0},{\"name\":\"invalid[0]\",\"value\":\"\",\"desc\":\"\",\"required\":0},{\"name\":\"model.str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"model.integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"model.stringList\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"model.integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0},{\"name\":\"model.s\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"model.s2\",\"value\":\"bbb\",\"example\":\"bbb\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[0].str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"modelList[0].integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"modelList[0].stringList[0]\",\"value\":\"\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"modelList[0].integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 1]).toJson()
            )
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"default\\\":\\\"[123, 456]\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"abc\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"123\\\"},\\\"def\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"abc\\\\\\\":\\\\\\\"123\\\\\\\",\\\\\\\"def\\\\\\\":\\\\\\\"456\\\\\\\"}\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"]\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"}\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"aaa\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"default\\\":\\\"[{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}}\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/form\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"form\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with form\",\"req_body_form\":[{\"name\":\"intArr[0]\",\"example\":\"123\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"intArr[1]\",\"example\":\"456\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.abc\",\"example\":\"123\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.def\",\"example\":\"456\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[0]\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[1]\",\"example\":\"123\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"invalid[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"model.integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"model.stringList\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"model.integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"},{\"name\":\"model.s\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.s2\",\"example\":\"bbb\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[0].str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"modelList[0].integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"modelList[0].stringList[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"modelList[0].integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"}],\"path\":\"/default/form\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"multipart/form-data\",\"example\":\"multipart/form-data\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 2]).toJson()
            )
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"default\\\":\\\"[123, 456]\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"abc\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"123\\\"},\\\"def\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"abc\\\\\\\":\\\\\\\"123\\\\\\\",\\\\\\\"def\\\\\\\":\\\\\\\"456\\\\\\\"}\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"]\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"}\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"aaa\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"default\\\":\\\"[{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}}\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/body\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"default\\\":\\\"[123, 456]\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"abc\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"123\\\"},\\\"def\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"abc\\\\\\\":\\\\\\\"123\\\\\\\",\\\\\\\"def\\\\\\\":\\\\\\\"456\\\\\\\"}\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"]\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"}\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"aaa\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"default\\\":\\\"[{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}}\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"type\":\"static\",\"title\":\"call with body\",\"req_body_form\":[],\"path\":\"/default/body\",\"req_body_is_json_schema\":true,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 3]).toJson()
            )
        }

        /**
         * use json-schema by default
         */
        fun testDoc2ItemsWithoutExpanded() {
            settings.formExpanded = false
            settings.queryExpanded = false
            val requests = ArrayList<Request>()
            val boundary = actionContext.createBoundary()
            classExporter.export(userCtrlPsiClass, requestOnly {
                requests.add(it)
            })
            boundary.waitComplete(false)
            classExporter.export(defaultCtrlPsiClass, requestOnly {
                requests.add(it)
            })
            boundary.waitComplete()
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"string\\\",\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/greeting\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"say hello\",\"path\":\"/user/greeting\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"not update anything\",\"req_headers\":[],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":true,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003enot update anything\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[0]).toJson()
            )
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"}},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"user regtime\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/get/{id}\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"get user info\",\"path\":\"/user/get/{id}\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[\"deprecated\"],\"req_query\":[{\"name\":\"id\",\"value\":0,\"desc\":\"user id\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"undone\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[1]).toJson()
            )
            val apiCntInUserCtrl = userCtrlPsiClass.methods.size
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"string\\\",\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/ctrl/name\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"current ctrl name\",\"path\":\"/user/ctrl/name\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 0]).toJson()
            )
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"default\\\":\\\"[123, 456]\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"abc\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"123\\\"},\\\"def\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"abc\\\\\\\":\\\\\\\"123\\\\\\\",\\\\\\\"def\\\\\\\":\\\\\\\"456\\\\\\\"}\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"]\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"}\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"aaa\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"default\\\":\\\"[{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}}\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/body\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with query\",\"path\":\"/default/body\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[{\"name\":\"intArr\",\"value\":\"[123, 456]\",\"example\":\"[123, 456]\",\"desc\":\"\",\"required\":0},{\"name\":\"amount\",\"value\":\"{\\\"abc\\\":\\\"123\\\",\\\"def\\\":\\\"456\\\"}\",\"example\":\"{\\\"abc\\\":\\\"123\\\",\\\"def\\\":\\\"456\\\"}\",\"desc\":\"\",\"required\":0},{\"name\":\"strings\",\"value\":\"[\\\"abc\\\",\\\"123\\\"]\",\"example\":\"[\\\"abc\\\",\\\"123\\\"]\",\"desc\":\"\",\"required\":0},{\"name\":\"invalid\",\"value\":\"[\\\"abc\\\",\\\"123\\\"}\",\"example\":\"[\\\"abc\\\",\\\"123\\\"}\",\"desc\":\"\",\"required\":0},{\"name\":\"model\",\"value\":\"{\\\"s\\\":\\\"aaa\\\",\\\"s2\\\":\\\"bbb\\\",\\\"stringList\\\":\\\"abc\\\"}\",\"example\":\"{\\\"s\\\":\\\"aaa\\\",\\\"s2\\\":\\\"bbb\\\",\\\"stringList\\\":\\\"abc\\\"}\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList\",\"value\":\"[{\\\"s\\\":\\\"aaa\\\",\\\"s2\\\":\\\"bbb\\\",\\\"stringList\\\":\\\"abc\\\"}}\",\"example\":\"[{\\\"s\\\":\\\"aaa\\\",\\\"s2\\\":\\\"bbb\\\",\\\"stringList\\\":\\\"abc\\\"}}\",\"desc\":\"\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 1]).toJson()
            )
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"default\\\":\\\"[123, 456]\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"abc\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"123\\\"},\\\"def\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"abc\\\\\\\":\\\\\\\"123\\\\\\\",\\\\\\\"def\\\\\\\":\\\\\\\"456\\\\\\\"}\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"]\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"}\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"aaa\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"default\\\":\\\"[{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}}\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/form\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"form\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with form\",\"req_body_form\":[{\"name\":\"intArr\",\"example\":\"[123, 456]\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount\",\"example\":\"{\\\"abc\\\":\\\"123\\\",\\\"def\\\":\\\"456\\\"}\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings\",\"example\":\"[\\\"abc\\\",\\\"123\\\"]\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"invalid\",\"example\":\"[\\\"abc\\\",\\\"123\\\"}\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model\",\"example\":\"{\\\"s\\\":\\\"aaa\\\",\\\"s2\\\":\\\"bbb\\\",\\\"stringList\\\":\\\"abc\\\"}\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList\",\"example\":\"[{\\\"s\\\":\\\"aaa\\\",\\\"s2\\\":\\\"bbb\\\",\\\"stringList\\\":\\\"abc\\\"}}\",\"type\":\"text\",\"required\":0,\"desc\":\"\"}],\"path\":\"/default/form\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"multipart/form-data\",\"example\":\"multipart/form-data\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 2]).toJson()
            )
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"default\\\":\\\"[123, 456]\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"abc\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"123\\\"},\\\"def\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"abc\\\\\\\":\\\\\\\"123\\\\\\\",\\\\\\\"def\\\\\\\":\\\\\\\"456\\\\\\\"}\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"]\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"}\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"aaa\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"default\\\":\\\"[{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}}\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/body\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"default\\\":\\\"[123, 456]\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"abc\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"123\\\"},\\\"def\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"abc\\\\\\\":\\\\\\\"123\\\\\\\",\\\\\\\"def\\\\\\\":\\\\\\\"456\\\\\\\"}\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"]\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"}\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\",\\\"default\\\":\\\"aaa\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}},\\\"default\\\":\\\"{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"default\\\":\\\"[{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}}\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"type\":\"static\",\"title\":\"call with body\",\"req_body_form\":[],\"path\":\"/default/body\",\"req_body_is_json_schema\":true,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 3]).toJson()
            )
        }

        /**
         * use json5
         */
        fun testDoc2ItemsWithJson5() {
            settings.yapiReqBodyJson5 = true
            settings.yapiResBodyJson5 = true
            val requests = ArrayList<Request>()
            val boundary = actionContext.createBoundary()
            classExporter.export(userCtrlPsiClass, requestOnly {
                requests.add(it)
            })
            boundary.waitComplete(false)
            classExporter.export(defaultCtrlPsiClass, requestOnly {
                requests.add(it)
            })
            boundary.waitComplete()
            assertEquals(
                "[{\"res_body\":\"\\\"\\\"\",\"query_path\":{\"path\":\"/user/greeting\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"say hello\",\"path\":\"/user/greeting\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"not update anything\",\"req_headers\":[],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":true,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"\\u003cp\\u003enot update anything\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[0]).toJson()!!.toUnixString()
            )
            assertEquals(
                "[{\"res_body\":\"{\\n    \\\"code\\\": 0, //response code\\n    \\\"msg\\\": \\\"success\\\", //message\\n    \\\"data\\\": { //response data\\n        \\\"id\\\": 0, //user id\\n        /**\\n         * user type\\n         * 1 :administration\\n         * 2 :a person, an animal or a plant\\n         * 3 :Anonymous visitor\\n         */\\n        \\\"type\\\": \\\"@pick([1,2,3])\\\",\\n        \\\"name\\\": \\\"Tony Stark\\\", //user name\\n        \\\"age\\\": 45, //user age\\n        \\\"sex\\\": 0,\\n        \\\"birthDay\\\": \\\"\\\", //user birthDay\\n        \\\"regtime\\\": \\\"\\\" //user regtime\\n    }\\n}\",\"query_path\":{\"path\":\"/user/get/{id}\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"get user info\",\"path\":\"/user/get/{id}\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[\"deprecated\"],\"req_query\":[{\"name\":\"id\",\"value\":0,\"desc\":\"user id\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"undone\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[1]).toJson()!!.toUnixString()
            )

            val apiCntInUserCtrl = userCtrlPsiClass.methods.size

            assertEquals(
                "[{\"res_body\":\"\\\"\\\"\",\"query_path\":{\"path\":\"/user/ctrl/name\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"current ctrl name\",\"path\":\"/user/ctrl/name\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 0]).toJson()!!.toUnixString()
            )
            assertEquals(
                "[{\"res_body\":\"{\\n    \\\"code\\\": 0, //response code\\n    \\\"msg\\\": \\\"\\\", //message\\n    \\\"data\\\": { //response data\\n        \\\"intArr\\\": [\\n            123,\\n            456\\n        ],\\n        \\\"amount\\\": {\\n            \\\"abc\\\": \\\"123\\\",\\n            \\\"def\\\": \\\"456\\\"\\n        },\\n        \\\"strings\\\": [\\n            \\\"abc\\\",\\n            \\\"123\\\"\\n        ],\\n        \\\"invalid\\\": [\\n            \\\"\\\"\\n        ],\\n        \\\"model\\\": {\\n            \\\"str\\\": \\\"\\\", //string field\\n            \\\"integer\\\": 0, //integer field\\n            \\\"stringList\\\": \\\"abc\\\", //stringList field\\n            \\\"integerArray\\\": [ //integerArray field\\n                0\\n            ],\\n            \\\"s\\\": \\\"aaa\\\",\\n            \\\"s2\\\": \\\"bbb\\\"\\n        },\\n        \\\"modelList\\\": [\\n            {\\n                \\\"str\\\": \\\"\\\", //string field\\n                \\\"integer\\\": 0, //integer field\\n                \\\"stringList\\\": [ //stringList field\\n                    \\\"\\\"\\n                ],\\n                \\\"integerArray\\\": [ //integerArray field\\n                    0\\n                ]\\n            }\\n        ]\\n    }\\n}\",\"query_path\":{\"path\":\"/default/body\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with query\",\"path\":\"/default/body\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[{\"name\":\"intArr[0]\",\"value\":123,\"example\":\"123\",\"desc\":\"\",\"required\":0},{\"name\":\"intArr[1]\",\"value\":456,\"example\":\"456\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.abc\",\"value\":\"123\",\"example\":\"123\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.def\",\"value\":\"456\",\"example\":\"456\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[0]\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[1]\",\"value\":\"123\",\"example\":\"123\",\"desc\":\"\",\"required\":0},{\"name\":\"invalid[0]\",\"value\":\"\",\"desc\":\"\",\"required\":0},{\"name\":\"model.str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"model.integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"model.stringList\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"model.integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0},{\"name\":\"model.s\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"model.s2\",\"value\":\"bbb\",\"example\":\"bbb\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[0].str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"modelList[0].integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"modelList[0].stringList[0]\",\"value\":\"\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"modelList[0].integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 1]).toJson()!!.toUnixString()
            )
            assertEquals(
                "[{\"res_body\":\"{\\n    \\\"code\\\": 0, //response code\\n    \\\"msg\\\": \\\"\\\", //message\\n    \\\"data\\\": { //response data\\n        \\\"intArr\\\": [\\n            123,\\n            456\\n        ],\\n        \\\"amount\\\": {\\n            \\\"abc\\\": \\\"123\\\",\\n            \\\"def\\\": \\\"456\\\"\\n        },\\n        \\\"strings\\\": [\\n            \\\"abc\\\",\\n            \\\"123\\\"\\n        ],\\n        \\\"invalid\\\": [\\n            \\\"\\\"\\n        ],\\n        \\\"model\\\": {\\n            \\\"str\\\": \\\"\\\", //string field\\n            \\\"integer\\\": 0, //integer field\\n            \\\"stringList\\\": \\\"abc\\\", //stringList field\\n            \\\"integerArray\\\": [ //integerArray field\\n                0\\n            ],\\n            \\\"s\\\": \\\"aaa\\\",\\n            \\\"s2\\\": \\\"bbb\\\"\\n        },\\n        \\\"modelList\\\": [\\n            {\\n                \\\"str\\\": \\\"\\\", //string field\\n                \\\"integer\\\": 0, //integer field\\n                \\\"stringList\\\": [ //stringList field\\n                    \\\"\\\"\\n                ],\\n                \\\"integerArray\\\": [ //integerArray field\\n                    0\\n                ]\\n            }\\n        ]\\n    }\\n}\",\"query_path\":{\"path\":\"/default/form\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"form\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with form\",\"req_body_form\":[{\"name\":\"intArr[0]\",\"example\":\"123\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"intArr[1]\",\"example\":\"456\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.abc\",\"example\":\"123\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.def\",\"example\":\"456\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[0]\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[1]\",\"example\":\"123\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"invalid[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"model.integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"model.stringList\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"model.integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"},{\"name\":\"model.s\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.s2\",\"example\":\"bbb\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[0].str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"modelList[0].integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"modelList[0].stringList[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"modelList[0].integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"}],\"path\":\"/default/form\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"multipart/form-data\",\"example\":\"multipart/form-data\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 2]).toJson()!!.toUnixString()
            )
            assertEquals(
                "[{\"res_body\":\"{\\n    \\\"code\\\": 0, //response code\\n    \\\"msg\\\": \\\"\\\", //message\\n    \\\"data\\\": { //response data\\n        \\\"intArr\\\": [\\n            123,\\n            456\\n        ],\\n        \\\"amount\\\": {\\n            \\\"abc\\\": \\\"123\\\",\\n            \\\"def\\\": \\\"456\\\"\\n        },\\n        \\\"strings\\\": [\\n            \\\"abc\\\",\\n            \\\"123\\\"\\n        ],\\n        \\\"invalid\\\": [\\n            \\\"\\\"\\n        ],\\n        \\\"model\\\": {\\n            \\\"str\\\": \\\"\\\", //string field\\n            \\\"integer\\\": 0, //integer field\\n            \\\"stringList\\\": \\\"abc\\\", //stringList field\\n            \\\"integerArray\\\": [ //integerArray field\\n                0\\n            ],\\n            \\\"s\\\": \\\"aaa\\\",\\n            \\\"s2\\\": \\\"bbb\\\"\\n        },\\n        \\\"modelList\\\": [\\n            {\\n                \\\"str\\\": \\\"\\\", //string field\\n                \\\"integer\\\": 0, //integer field\\n                \\\"stringList\\\": [ //stringList field\\n                    \\\"\\\"\\n                ],\\n                \\\"integerArray\\\": [ //integerArray field\\n                    0\\n                ]\\n            }\\n        ]\\n    }\\n}\",\"query_path\":{\"path\":\"/default/body\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\n    \\\"intArr\\\": [\\n        123,\\n        456\\n    ],\\n    \\\"amount\\\": {\\n        \\\"abc\\\": \\\"123\\\",\\n        \\\"def\\\": \\\"456\\\"\\n    },\\n    \\\"strings\\\": [\\n        \\\"abc\\\",\\n        \\\"123\\\"\\n    ],\\n    \\\"invalid\\\": [\\n        \\\"\\\"\\n    ],\\n    \\\"model\\\": {\\n        \\\"str\\\": \\\"\\\", //string field\\n        \\\"integer\\\": 0, //integer field\\n        \\\"stringList\\\": \\\"abc\\\", //stringList field\\n        \\\"integerArray\\\": [ //integerArray field\\n            0\\n        ],\\n        \\\"s\\\": \\\"aaa\\\",\\n        \\\"s2\\\": \\\"bbb\\\"\\n    },\\n    \\\"modelList\\\": [\\n        {\\n            \\\"str\\\": \\\"\\\", //string field\\n            \\\"integer\\\": 0, //integer field\\n            \\\"stringList\\\": [ //stringList field\\n                \\\"\\\"\\n            ],\\n            \\\"integerArray\\\": [ //integerArray field\\n                0\\n            ]\\n        }\\n    ]\\n}\",\"type\":\"static\",\"title\":\"call with body\",\"req_body_form\":[],\"path\":\"/default/body\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 3]).toJson()!!.toUnixString()
            )
        }
    }

    class YapiFormatterWithDemoTest : YapiFormatterTest() {
        override fun customConfig(): String {
            return "method.additional.header[!@com.itangcent.annotation.Public]={name: \"token\",value: \"\",desc: \"auth token\",required:true, example:\"123456\"}\n" +
                    "#[converts]*\n" +
                    "#The ObjectId and Date will be parsed as strings\n" +
                    "json.rule.convert[org.bson.types.ObjectId]=java.lang.String\n" +
                    "json.rule.convert[java.util.Date]=java.lang.String\n" +
                    "json.rule.convert[java.sql.Timestamp]=java.lang.String\n" +
                    "json.rule.convert[java.time.LocalDateTime]=java.lang.String\n" +
                    "json.rule.convert[java.time.LocalDate]=java.lang.String\n" +
                    "field.demo=#demo\n" +
                    "api.open=@com.itangcent.annotation.Public\n" +
                    "api.status[#undone]=undone\n" +
                    "api.tag[@java.lang.Deprecated]=deprecated"
        }

        /**
         * use json-schema by default
         */
        fun testDoc2Items() {
            val requests = ArrayList<Request>()
            val boundary = actionContext.createBoundary()
            classExporter.export(userCtrlPsiClass, requestOnly {
                requests.add(it)
            })
            boundary.waitComplete(false)
            classExporter.export(defaultCtrlPsiClass, requestOnly {
                requests.add(it)
            })
            boundary.waitComplete()
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"string\\\",\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/greeting\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"say hello\",\"path\":\"/user/greeting\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"not update anything\",\"req_headers\":[],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":true,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003enot update anything\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[0]).toJson()
            )
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"}},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"user name\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"user regtime\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/get/{id}\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"get user info\",\"path\":\"/user/get/{id}\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[\"deprecated\"],\"req_query\":[{\"name\":\"id\",\"value\":0,\"desc\":\"user id\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"undone\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[1]).toJson()
            )
            val apiCntInUserCtrl = userCtrlPsiClass.methods.size
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"string\\\",\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/ctrl/name\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"current ctrl name\",\"path\":\"/user/ctrl/name\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 0]).toJson()
            )
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"}},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"aaa\\\":{\\\"type\\\":\\\"string\\\"},\\\"ddd\\\":{\\\"type\\\":\\\"string\\\"}}},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"}},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"}},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}}},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}}}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/body\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with query\",\"path\":\"/default/body\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[{\"name\":\"intArr[0]\",\"value\":666,\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"intArr[1]\",\"value\":888,\"example\":\"888\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.aaa\",\"value\":\"666\",\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.ddd\",\"value\":\"888\",\"example\":\"888\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[0]\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[1]\",\"value\":\"666\",\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"invalid[0]\",\"value\":\"\",\"example\":\"{\\\"aaa\\\",\\\"666\\\"]\",\"desc\":\"\",\"required\":0},{\"name\":\"model.str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"model.integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"model.stringList\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"model.integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0},{\"name\":\"model.s\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"model.s2\",\"value\":\"bbb\",\"example\":\"bbb\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[0].str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"modelList[0].integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"modelList[0].stringList[0]\",\"value\":\"\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"modelList[0].integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0},{\"name\":\"modelList[1].s\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[1].stringList\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[1].s2\",\"value\":\"bbb\",\"example\":\"bbb\",\"desc\":\"\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 1]).toJson()
            )
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"}},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"aaa\\\":{\\\"type\\\":\\\"string\\\"},\\\"ddd\\\":{\\\"type\\\":\\\"string\\\"}}},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"}},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"}},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}}},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}}}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/form\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"form\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with form\",\"req_body_form\":[{\"name\":\"intArr[0]\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"intArr[1]\",\"example\":\"888\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.aaa\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.ddd\",\"example\":\"888\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[0]\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[1]\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"invalid[0]\",\"example\":\"{\\\"aaa\\\",\\\"666\\\"]\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"model.integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"model.stringList\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"model.integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"},{\"name\":\"model.s\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.s2\",\"example\":\"bbb\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[0].str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"modelList[0].integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"modelList[0].stringList[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"modelList[0].integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"},{\"name\":\"modelList[1].s\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[1].stringList\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[1].s2\",\"example\":\"bbb\",\"type\":\"text\",\"required\":0,\"desc\":\"\"}],\"path\":\"/default/form\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"multipart/form-data\",\"example\":\"multipart/form-data\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 2]).toJson()
            )
            assertEquals(
                "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"}},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"aaa\\\":{\\\"type\\\":\\\"string\\\"},\\\"ddd\\\":{\\\"type\\\":\\\"string\\\"}}},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"}},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"}},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}}},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}}}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/body\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"}},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"aaa\\\":{\\\"type\\\":\\\"string\\\"},\\\"ddd\\\":{\\\"type\\\":\\\"string\\\"}}},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"}},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"}},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}}},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}}}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"type\":\"static\",\"title\":\"call with body\",\"req_body_form\":[],\"path\":\"/default/body\",\"req_body_is_json_schema\":true,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 3]).toJson()
            )
        }

        /**
         * use json5
         */
        fun testDoc2ItemsWithJson5() {
            settings.yapiReqBodyJson5 = true
            settings.yapiResBodyJson5 = true
            val requests = ArrayList<Request>()
            val boundary = actionContext.createBoundary()
            classExporter.export(userCtrlPsiClass, requestOnly {
                requests.add(it)
            })
            boundary.waitComplete(false)
            classExporter.export(defaultCtrlPsiClass, requestOnly {
                requests.add(it)
            })
            boundary.waitComplete()
            assertEquals(
                "[{\"res_body\":\"\\\"\\\"\",\"query_path\":{\"path\":\"/user/greeting\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"say hello\",\"path\":\"/user/greeting\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"not update anything\",\"req_headers\":[],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":true,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"\\u003cp\\u003enot update anything\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[0]).toJson()!!.toUnixString()
            )
            assertEquals(
                "[{\"res_body\":\"{\\n    \\\"code\\\": 0, //response code\\n    \\\"msg\\\": \\\"success\\\", //message\\n    \\\"data\\\": { //response data\\n        \\\"id\\\": 0, //user id\\n        /**\\n         * user type\\n         * 1 :administration\\n         * 2 :a person, an animal or a plant\\n         * 3 :Anonymous visitor\\n         */\\n        \\\"type\\\": \\\"@pick([1,2,3])\\\",\\n        \\\"name\\\": \\\"Tony Stark\\\", //user name\\n        \\\"age\\\": 45, //user age\\n        \\\"sex\\\": 0,\\n        \\\"birthDay\\\": \\\"\\\", //user birthDay\\n        \\\"regtime\\\": \\\"\\\" //user regtime\\n    }\\n}\",\"query_path\":{\"path\":\"/user/get/{id}\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"get user info\",\"path\":\"/user/get/{id}\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[\"deprecated\"],\"req_query\":[{\"name\":\"id\",\"value\":0,\"desc\":\"user id\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"undone\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[1]).toJson()!!.toUnixString()
            )

            val apiCntInUserCtrl = userCtrlPsiClass.methods.size

            assertEquals(
                "[{\"res_body\":\"\\\"\\\"\",\"query_path\":{\"path\":\"/user/ctrl/name\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"current ctrl name\",\"path\":\"/user/ctrl/name\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 0]).toJson()!!.toUnixString()
            )
            assertEquals(
                "[{\"res_body\":\"{\\n    \\\"code\\\": 0, //response code\\n    \\\"msg\\\": \\\"\\\", //message\\n    \\\"data\\\": { //response data\\n        \\\"intArr\\\": [\\n            666,\\n            888\\n        ],\\n        \\\"amount\\\": {\\n            \\\"aaa\\\": \\\"666\\\",\\n            \\\"ddd\\\": \\\"888\\\"\\n        },\\n        \\\"strings\\\": [\\n            \\\"aaa\\\",\\n            \\\"666\\\"\\n        ],\\n        \\\"invalid\\\": [\\n            \\\"\\\"\\n        ],\\n        \\\"model\\\": {\\n            \\\"str\\\": \\\"\\\", //string field\\n            \\\"integer\\\": 0, //integer field\\n            \\\"stringList\\\": \\\"abc\\\", //stringList field\\n            \\\"integerArray\\\": [ //integerArray field\\n                0\\n            ],\\n            \\\"s\\\": \\\"aaa\\\",\\n            \\\"s2\\\": \\\"bbb\\\"\\n        },\\n        \\\"modelList\\\": [\\n            {\\n                \\\"str\\\": \\\"\\\", //string field\\n                \\\"integer\\\": 0, //integer field\\n                \\\"stringList\\\": [ //stringList field\\n                    \\\"\\\"\\n                ],\\n                \\\"integerArray\\\": [ //integerArray field\\n                    0\\n                ]\\n            },\\n            {\\n                \\\"s\\\": \\\"aaa\\\",\\n                \\\"stringList\\\": \\\"abc\\\",\\n                \\\"s2\\\": \\\"bbb\\\"\\n            }\\n        ]\\n    }\\n}\",\"query_path\":{\"path\":\"/default/body\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with query\",\"path\":\"/default/body\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[{\"name\":\"intArr[0]\",\"value\":666,\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"intArr[1]\",\"value\":888,\"example\":\"888\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.aaa\",\"value\":\"666\",\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.ddd\",\"value\":\"888\",\"example\":\"888\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[0]\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[1]\",\"value\":\"666\",\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"invalid[0]\",\"value\":\"\",\"example\":\"{\\\"aaa\\\",\\\"666\\\"]\",\"desc\":\"\",\"required\":0},{\"name\":\"model.str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"model.integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"model.stringList\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"model.integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0},{\"name\":\"model.s\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"model.s2\",\"value\":\"bbb\",\"example\":\"bbb\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[0].str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"modelList[0].integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"modelList[0].stringList[0]\",\"value\":\"\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"modelList[0].integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0},{\"name\":\"modelList[1].s\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[1].stringList\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[1].s2\",\"value\":\"bbb\",\"example\":\"bbb\",\"desc\":\"\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 1]).toJson()!!.toUnixString()
            )
            assertEquals(
                "[{\"res_body\":\"{\\n    \\\"code\\\": 0, //response code\\n    \\\"msg\\\": \\\"\\\", //message\\n    \\\"data\\\": { //response data\\n        \\\"intArr\\\": [\\n            666,\\n            888\\n        ],\\n        \\\"amount\\\": {\\n            \\\"aaa\\\": \\\"666\\\",\\n            \\\"ddd\\\": \\\"888\\\"\\n        },\\n        \\\"strings\\\": [\\n            \\\"aaa\\\",\\n            \\\"666\\\"\\n        ],\\n        \\\"invalid\\\": [\\n            \\\"\\\"\\n        ],\\n        \\\"model\\\": {\\n            \\\"str\\\": \\\"\\\", //string field\\n            \\\"integer\\\": 0, //integer field\\n            \\\"stringList\\\": \\\"abc\\\", //stringList field\\n            \\\"integerArray\\\": [ //integerArray field\\n                0\\n            ],\\n            \\\"s\\\": \\\"aaa\\\",\\n            \\\"s2\\\": \\\"bbb\\\"\\n        },\\n        \\\"modelList\\\": [\\n            {\\n                \\\"str\\\": \\\"\\\", //string field\\n                \\\"integer\\\": 0, //integer field\\n                \\\"stringList\\\": [ //stringList field\\n                    \\\"\\\"\\n                ],\\n                \\\"integerArray\\\": [ //integerArray field\\n                    0\\n                ]\\n            },\\n            {\\n                \\\"s\\\": \\\"aaa\\\",\\n                \\\"stringList\\\": \\\"abc\\\",\\n                \\\"s2\\\": \\\"bbb\\\"\\n            }\\n        ]\\n    }\\n}\",\"query_path\":{\"path\":\"/default/form\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"form\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with form\",\"req_body_form\":[{\"name\":\"intArr[0]\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"intArr[1]\",\"example\":\"888\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.aaa\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.ddd\",\"example\":\"888\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[0]\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[1]\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"invalid[0]\",\"example\":\"{\\\"aaa\\\",\\\"666\\\"]\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"model.integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"model.stringList\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"model.integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"},{\"name\":\"model.s\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.s2\",\"example\":\"bbb\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[0].str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"modelList[0].integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"modelList[0].stringList[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"modelList[0].integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"},{\"name\":\"modelList[1].s\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[1].stringList\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[1].s2\",\"example\":\"bbb\",\"type\":\"text\",\"required\":0,\"desc\":\"\"}],\"path\":\"/default/form\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"multipart/form-data\",\"example\":\"multipart/form-data\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 2]).toJson()!!.toUnixString()
            )
            assertEquals(
                "[{\"res_body\":\"{\\n    \\\"code\\\": 0, //response code\\n    \\\"msg\\\": \\\"\\\", //message\\n    \\\"data\\\": { //response data\\n        \\\"intArr\\\": [\\n            666,\\n            888\\n        ],\\n        \\\"amount\\\": {\\n            \\\"aaa\\\": \\\"666\\\",\\n            \\\"ddd\\\": \\\"888\\\"\\n        },\\n        \\\"strings\\\": [\\n            \\\"aaa\\\",\\n            \\\"666\\\"\\n        ],\\n        \\\"invalid\\\": [\\n            \\\"\\\"\\n        ],\\n        \\\"model\\\": {\\n            \\\"str\\\": \\\"\\\", //string field\\n            \\\"integer\\\": 0, //integer field\\n            \\\"stringList\\\": \\\"abc\\\", //stringList field\\n            \\\"integerArray\\\": [ //integerArray field\\n                0\\n            ],\\n            \\\"s\\\": \\\"aaa\\\",\\n            \\\"s2\\\": \\\"bbb\\\"\\n        },\\n        \\\"modelList\\\": [\\n            {\\n                \\\"str\\\": \\\"\\\", //string field\\n                \\\"integer\\\": 0, //integer field\\n                \\\"stringList\\\": [ //stringList field\\n                    \\\"\\\"\\n                ],\\n                \\\"integerArray\\\": [ //integerArray field\\n                    0\\n                ]\\n            },\\n            {\\n                \\\"s\\\": \\\"aaa\\\",\\n                \\\"stringList\\\": \\\"abc\\\",\\n                \\\"s2\\\": \\\"bbb\\\"\\n            }\\n        ]\\n    }\\n}\",\"query_path\":{\"path\":\"/default/body\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\n    \\\"intArr\\\": [\\n        666,\\n        888\\n    ],\\n    \\\"amount\\\": {\\n        \\\"aaa\\\": \\\"666\\\",\\n        \\\"ddd\\\": \\\"888\\\"\\n    },\\n    \\\"strings\\\": [\\n        \\\"aaa\\\",\\n        \\\"666\\\"\\n    ],\\n    \\\"invalid\\\": [\\n        \\\"\\\"\\n    ],\\n    \\\"model\\\": {\\n        \\\"str\\\": \\\"\\\", //string field\\n        \\\"integer\\\": 0, //integer field\\n        \\\"stringList\\\": \\\"abc\\\", //stringList field\\n        \\\"integerArray\\\": [ //integerArray field\\n            0\\n        ],\\n        \\\"s\\\": \\\"aaa\\\",\\n        \\\"s2\\\": \\\"bbb\\\"\\n    },\\n    \\\"modelList\\\": [\\n        {\\n            \\\"str\\\": \\\"\\\", //string field\\n            \\\"integer\\\": 0, //integer field\\n            \\\"stringList\\\": [ //stringList field\\n                \\\"\\\"\\n            ],\\n            \\\"integerArray\\\": [ //integerArray field\\n                0\\n            ]\\n        },\\n        {\\n            \\\"s\\\": \\\"aaa\\\",\\n            \\\"stringList\\\": \\\"abc\\\",\\n            \\\"s2\\\": \\\"bbb\\\"\\n        }\\n    ]\\n}\",\"type\":\"static\",\"title\":\"call with body\",\"req_body_form\":[],\"path\":\"/default/body\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"\\u003cp\\u003e\\u003c/p\\u003e\"}]",
                yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 3]).toJson()!!.toUnixString()
            )
        }
    }
}